﻿using AutoMapper;
using FluentValidation;
using Nuclear.Mappings;
using Nuclear.Models.DtoModels;
using Nuclear.Services;
using Nuclear.Validations.DtoValidations;

namespace Nuclear;

public static class ServicesRegistry
{
    public static void AddGeneralServices(this IServiceCollection services)
    {
        services.AddScoped<IDbService, DbService>();
        var mapperConfiguration = new MapperConfiguration(cfg => {
            cfg.AddProfile<MapProfile>();
        });
        var mapper = mapperConfiguration.CreateMapper();
        services.AddSingleton<IMapper>(mapper);
    }

    public static void AddValidators(this IServiceCollection services)
    {
        services.AddScoped<IValidator<GenerateConsumeCodeRequestDto>, GenerateConsumeCodeRequestDtoValidator>();
        services.AddScoped<IValidator<UseConsumeCodeRequestDto>, UseConsumeCodeRequestDtoValidator>();
        services.AddScoped<IValidator<MerchantLoginRequestDto>, MerchantLoginRequestDtoValidator>();
        services.AddScoped<IValidator<GetConsumeCodesRequestDto>, GetConsumeCodeRequestDtoValidator>();
    }
}